<template>
	<view class="pl-20 pr-20">
		<view class="list">
			<u-list :height="swiperHeight" @scrolltolower="scrolltolower" v-if="dataList.length > 0">
				<view class="mt-20">
					<view class="sety-num" v-for="(goIm, goIx) in dataList" :key="goIx" @click="onRadio(goIm)">
						<image class="img" :src="goIm.shareImageUrl || '../../static/logo.png'" />
						<view class="tbx">
							<text>{{goIm.name}}</text>
							<view class="flex justify-between align-center">
								<view class="line-red">
									<text class="fsize-22">￥</text>
									<text class="fsize-32">{{goIm.salePrice}}</text>
								</view>
							</view>
						</view>
						<view class="shrink0 ml-20">
							<u-icon name="arrow-right" color="#606266" size="22" />
						</view>
					</view>
				</view>
				
				<!-- <u-loadmore :status="loadmore.status" :icon-type="loadmore.iconType"
					:load-text="loadmore.loadText.loadText" margin-top="10" margin-bottom="10"/> -->
			</u-list>
		</view>
		<!-- 无数据时默认显示 -->
		<view class="emptybox" v-if="dataList.length == 0">
			<u-empty icon-size="150" text="暂无数据" mode="data"></u-empty>
		</view>
		<!-- <u-gap height="80"></u-gap> -->
		<!-- <view class="bottom-button">
			<u-button type="primary" color="#fa436a" text="确认选择" @click="onNavigateBack"></u-button>
		</view> -->
	</view>
</template>

<script>
	import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		mixins:[listHeightMixin],
		data() {
			return {
				loadmore: {
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					},
				},
				searchData: {
					name: '',
					page: 1,
					limit: 100
				},
				dataList: [],
				nels:[],
			}
		},
		onLoad(options) {
			this.getPageList()
		},
		methods: {
			onRadio(row){
				let newArr = [{
					itemId: row.id,
					nums: 1,
					name: row.name,
					price: row.salePrice,
					stockholderDiscount: row.stockholderDiscount
				}]
				uni.$emit('add-pct', newArr)
				uni.navigateBack()
			},
			// 搜索事件
			onSearch() {
				this.searchData.page = 1
				this.dataList = []
				this.getPageList()
			},
			getPageList() {
				this.$reqPost('ProjectCategoryCardItemList', this.searchData).then(res => {
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.loadmore.status = 'loadmore';
						this.searchData.page++;
					} else {
						// 数据已加载完毕
						this.loadmore.status = 'nomore';
					}
				})
			},
			scrolltolower() {
				if (this.loadmore.status === 'loadmore') {
					this.getPageList();
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.sety-num{
		padding: 20rpx;
		display:flex;
		align-items: center;
		margin-bottom: 20rpx;
		border-radius: 10rpx;
		background-color: #fff;
		.img{
			width: 100rpx;
			height: 100rpx;
			border-radius: 10rpx;
			flex-shrink: 0;
			margin-right: 10px;
		}
		.tbx{
			width: 100%;
			display:flex;
			flex-direction: column;
			justify-content: space-between;
		}
	}
</style>
